<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>时钟</title>

<style>
body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #a8dadc;
    margin: 0;
}
.clock {
    position: relative;
    width: 300px;
    height: 300px;
    border: 10px solid #1d3557;
    border-radius: 50%;
    background-color: #457b9d;
}
.hand {
    position: absolute;
    width: 50%;
    background-color: #e63946;
    transform-origin: 100%;
    top: 50%;
    transform: rotate(90deg);
    transition: all 0.05s;
    border-radius: 10px;
}
.hour {
    height: 8px;
}
.minute {
    height: 6px;
    background-color: #f1faee;
}
.second {
    height: 4px;
    background-color: #a8dadc;
}
.center {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: #1d3557;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<div class="clock">
  <div class="hand hour" id="hour"></div>
  <div class="hand minute" id="minute"></div>
  <div class="hand second" id="second"></div>
  <div class="center"></div>
</div>
</body>
<script>  
const hourHand = document.getElementById('hour');  
const minuteHand = document.getElementById('minute');  
const secondHand = document.getElementById('second');  
  
function setClock() {  
  const now = new Date();  
  const secondsRatio = now.getSeconds() / 60;  
  const minutesRatio = (secondsRatio + now.getMinutes()) / 60;  
  const hoursRatio = (minutesRatio + now.getHours()) / 12;  
  
  setTransform(secondHand, secondsRatio * 360);  
  setTransform(minuteHand, minutesRatio * 360);  
  setTransform(hourHand, hoursRatio * 360);  
}  
  
function setTransform(element, rotation) {  
  element.style.transform = `rotate(${rotation + 90}deg)`; 
}  
  
setInterval(setClock, 1000);  
setClock();  
</script>
</html>
